package vip.zhenzicheng;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.cloud.zookeeper.serviceregistry.ServiceInstanceRegistration;
import org.springframework.cloud.zookeeper.serviceregistry.ZookeeperRegistration;
import org.springframework.cloud.zookeeper.serviceregistry.ZookeeperServiceRegistry;
import org.springframework.stereotype.Component;

/**
 * @author zhenzicheng
 * @DESCRIPTION:
 * @DATE: 2022/04/25 1:41 PM
 */
@Component
public class ApplicationRunner1 implements ApplicationRunner {
  @Autowired
  private ZookeeperServiceRegistry serviceRegistry;

  @Override
  public void run(ApplicationArguments args) {
    ZookeeperRegistration registration = ServiceInstanceRegistration.builder()
        .defaultUriSpec()
        .address("anyUrl")
        .port(10)
        .name("/a/b/c/d/anotherservice")
        .build();
    this.serviceRegistry.register(registration);
  }
}
